<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 函数对象
      function sum(n) {
        if (sum.r === undefined) {
          sum.r = 0;
        }
        sum.r += n;
        return sum;
      }
      sum.toString = function () {
        return this.r;
      };
      const res = sum(1)(3)(4) - 30; // Number(sum) - 30
      console.log(res);
      console.log(sum.r);
    </script>
  </body>
</html>
